package com.controller;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.util.HashMap;

import javax.servlet.http.HttpServletRequest;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.common.models.RetResult;
import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken;
import com.service.area.AreaService;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;

/**
 * 
* @ClassName: AreaController
* @Description: 地区service接口
* @author hlq
* @date 2017年12月11日 下午3:19:45
*
 */
@Api(tags="地区单模块",produces = "application/json")
@RestController
@RequestMapping("/area")
public class AreaController {
	
	@Autowired
	private AreaService areaService;
	
	@ApiOperation(value = "根据城市Id获取区县列表", notes = "请求参数：<br>cityId:城市Id")
	@RequestMapping(value="/getDistrictList",method=RequestMethod.POST)
	public RetResult getDistrictList(@RequestParam String data){
		  
		HashMap<String,Object> params = new Gson().fromJson(data, new TypeToken<HashMap<String,Object>>(){}.getType());
		
		return areaService.getDistrictList(params);
	}
	
	@RequestMapping(value="/getDistrictList2",method=RequestMethod.POST)
	public RetResult getDistrictList2(@RequestBody String data){
		  
		HashMap<String,Object> params = new Gson().fromJson(data, new TypeToken<HashMap<String,Object>>(){}.getType());
		
		return areaService.getDistrictList(params);
	}
	
	@ApiOperation(value = "获取城市列表", notes = "")
	@RequestMapping(value="/getCityList",method=RequestMethod.POST)
	public RetResult getCityList(HttpServletRequest request){
		return areaService.getCityList();
	}
	
	@ApiOperation(value = "获取热门城市列表", notes = "")
	@RequestMapping(value="/getHotCityList",method=RequestMethod.POST)
	public RetResult getHotCityList(){
		
		return areaService.getHotCityList();
	}
	
	@ApiOperation(value = "根据城市名称获取该城市的id接口", notes = "请求参数：<br>city:城市名称 <br>")
	@RequestMapping(value="/getCityIdByCity",method=RequestMethod.POST)
	public RetResult getCityIdByCity(@RequestParam String data){
		HashMap<String,Object> params = new Gson().fromJson(data, new TypeToken<HashMap<String,Object>>(){}.getType());
		return areaService.getCityIdByCity(params);
	}
}
